/*
	Copyright 2012 J. Gohlke
	Licensed under the Apache License, Version 2.0 (the
	"License"); you may not use this file except in
	compliance with the License. You may obtain a copy
	of the License at

	http://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in
	writing, software distributed under the License is
	distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
	OR CONDITIONS OF ANY KIND, either express or
	implied. See the License for the specific language
	governing permissions and limitations under the
	License
 */
package com.gohlke.lwo.textures;

/**
 *
 * @author David Wise
 * 
 * Specifies how the color of the texture 
 * is derived for areas outside the image.
 * 
 * If no wrap options are specified, 1 is assumed.
 */
public enum WrapType {
    /*
     * Areas outside the image are assumed to be black. 
     * The ultimate effect of this depends on the opacity settings. 
     * For an additive texture layer on the color channel, 
     * the final color will come from the preceding layers or from 
     * the base color of the surface.
     */
    Reset (0),
    /*
     * The image is repeated or tiled.
     */
    Repeat (1),
    /*
     * Like repeat, but alternate tiles are mirror-reversed.
     */
    Mirror (2),
    /*
     * The color is taken from the image's nearest edge pixel.
     */
    Edge (3);

    
    private final int index;
    
    WrapType(int index) { this.index = index; }
    
    public int index() { return this.index; }
    
    public static WrapType from(int index) {
        for (WrapType g : WrapType.values())
            if (g.index == index)
                return g;
        return null;
    }
    
}
